﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "学生选课管理 - 添加课程向导");
		
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		termId = event.getArg("TermID", event.getArg("TID"));
		stuId = event.getArg("STU");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		currentTab = event.getArg("TabID", "labWizard");
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		structInsert(targetArgs, "TSK", taskId, true);
		structInsert(targetArgs, "TT", taskType, true);
		
		if ( len(taskId) and len(taskType) ) {
			switch(taskType){
				case "C":
					sql = "SELECT 
								t_institute.institute_short, 
								t_course.course_name, 
								t_course.course_credit, 
								t_teacher.tch_name, 
								a.task_time, 
								a.task_place 
							FROM 
								t_common_task a
								INNER JOIN t_course ON t_course.cid = a.cid 
								INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
								INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							WHERE 
								a.tsk_id = :taskId ";
					break;
	
				case "P":
					sql = "SELECT 
								t_institute.institute_short, 
								t_course.course_name, 
								t_course.course_credit, 
								t_teacher.tch_name, 
								a.task_time, 
								a.task_place 
							FROM 
								t_task a
								INNER JOIN t_course ON t_course.cid = a.cid 
								INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
								INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							WHERE 
								a.tsk_id = :taskId ";
					break;
				
				case "R":
					sql = "SELECT 
								t_institute.institute_short, 
								t_course.course_name, 
								t_course.course_credit, 
								t_teacher.tch_name, 
								a.task_time, 
								a.task_place 
							FROM 
								t_reopen_task a
								INNER JOIN t_course ON t_course.cid = a.cid 
								INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
								INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							WHERE 
								a.tsk_id = :taskId ";
					break;
				
				case "T":
					sql = "SELECT 
								t_institute.institute_short, 
								t_course.course_name, 
								t_course.course_credit, 
								t_teacher.tch_name, 
								a.task_time, 
								a.task_place 
							FROM 
								t_sport_task a
								INNER JOIN t_course ON t_course.cid = a.cid 
								INNER JOIN t_institute ON t_institute.institute_id = t_course.institute_id 
								INNER JOIN t_teacher ON t_teacher.tch_id = a.tch_id 
							WHERE 
								a.tsk_id = :taskId ";
					break;
			}
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="taskId", value=taskId, cfsqltype="cf_sql_varchar" );
			rs_task = queryObj.execute( sql=sql ).getResult();
		}
		if ( len(stuId) ) {
			sql = "SELECT 
						t_student.stu_id, 
						t_student.stu_name, 
						t_student.stu_sex, 
						(SELECT t_class.cls_name FROM t_class WHERE t_class.cls_id =  t_student.cls_id ) cls_name 
					FROM 
						t_student 
					WHERE 
						t_student.stu_id = :studentId ";
			queryObj = new query( datasource=application.dnsSlave );
			queryObj.addParam( name="studentId", value=stuId, cfsqltype="cf_sql_varchar" );
			rs_student = queryObj.execute( sql=sql ).getResult();
			
		}

	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('taskClassDetail', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教学任务调整</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 info"></i>选课相关属性设置
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="programCourse">
				<div class="UItab2">
					<div class="tabLables">
                        <cfif (rs_task.recordCount GT 0) and (rs_student.recordCount GT 0) >
							<span <cfif currentTab eq "labWizard">class="active"</cfif> id="labWizard" tabTarget="Wizard">学生选课相关设置</span>
							<cfelse>
							<span class="active" id="labError" tabTarget="Error">操作有误</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
                <cfif (rs_task.recordCount GT 0) and (rs_student.recordCount GT 0) >
					
					<div id="Wizard" class="tabContent">
						
						<div class="noticeBlock">
							<h3>您正向学生</h3>
							<table>
								<tr>
									<td>学号</td>
									<td>姓名</td>
									<td>性别</td>
									<td>行政班</td>
								</tr>
                                <tr>
									<td class="numeric"><cfoutput>#rs_student.stu_id#</cfoutput></td>
									<td><cfoutput>#rs_student.stu_name#</cfoutput></td>
									<td><cfif rs_student.stu_sex eq "1">男<cfelse>女</cfif></td>
									<td><cfoutput>#rs_student.cls_name#</cfoutput></td>
								</tr>
							</table>
							<p>添加课程</p>
							<table>
								<tr>
									<td>任课单位</td>
									<td>课程</td>
									<td>学分</td>
									<td>教师</td>
									<td>上课时间</td>
									<td>上课地点</td>
								</tr>
                                <tr>
									<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
									<td><cfoutput>#rs_task.course_name#</cfoutput></td>
									<td class="numeric"><cfoutput>#numberFormat( rs_task.course_credit, "_.__" )#</cfoutput></td>
									<td><cfoutput>#rs_task.tch_name#</cfoutput></td>
									<td><cfif len(rs_task.task_time)><cfoutput>#replace( mathAdvice.convertTaskTime( rs_task.task_time ), ",", "、", "ALL")#</cfoutput></cfif></td>
									<td><cfoutput>#replace( rs_task.task_place, ",", "、", "ALL")#</cfoutput></td>
								</tr>
							</table>
							<hr/>
						</div>
						
						<form id="formAdd" onSubmit="javascript:return processVerfiyForm('formAdd');" class="formWrapper" method="post" action="<cfoutput>#buildURL('applyCourseStudentDo')#</cfoutput>">

							<input name="TermID" type="hidden" value="<cfoutput>#termId#</cfoutput>" />
							<input name="TaskType" type="hidden" value="<cfoutput>#taskType#</cfoutput>" />
							<input name="TaskID" type="hidden" value="<cfoutput>#taskId#</cfoutput>" />
							<input name="StudentID" type="hidden" value="<cfoutput>#stuId#</cfoutput>" />
							
							<div class="label">
								<b>修读方式</b>
								<input name="StudyType" value="N" type="radio" class="typeRadio" checked="checked" />正常
								<!---<input name="StudyType" value="R" type="radio" class="typeRadio" />重新学习 &nbsp;&nbsp;
								<input name="StudyType" value="F" type="radio" class="typeRadio" />补修 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								
								<input name="StudyType" value="S" type="radio" class="typeRadio" />双学位 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="StudyType" value="A" type="radio" class="typeRadio" />辅修
								<p class="notice">
									重新学习: 正常修读课程未合格或需要再次修读课程以提高课程成绩. <br/>
									补修: 学籍异动学生可跟班修读培养方案的低年级课程. 若之前学期存在漏选课的学生, 也可申请跟班修读. <br/>
									双学位、辅修: 申请辅修专业或双学位学生选择修读额外专业课程
								</p>--->
							</div>

							<div class="label" id="CP_NRF">
								<b>课程性质</b>
								<input name="CourseProperty" value="1" type="radio" class="typeRadio" />必修 
								<input name="CourseProperty" value="2" type="radio" class="typeRadio" checked="checked" />限选 &nbsp;&nbsp;
								<!---<input name="CourseProperty" value="3" type="radio" class="typeRadio" />任选 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="CourseProperty" value="5" type="radio" class="typeRadio" />实践 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input name="CourseProperty" value="9" type="radio" class="typeRadio" />其他
								<p class="notice">学生修读课程如果在主修专业培养方案有明确标注, 在生成学生课程成绩时会自动根据学生所在专业年级培养方案自动修正课程性质.</p>--->
							</div>

							<!---<div class="label hidden_elem" id="CP_A">
								<b>辅修课程</b>
								<input name="CourseProperty" value="4" type="radio" class="typeRadio" />辅修
								<p class="notice">此项课程性质仅仅适用于该学生参加了某专业的辅修计划, 并选择该辅修计划的课程选课. </p>
							</div>
							
							<div class="label hidden_elem" id="CP_S">
								<b>双学位课程性质</b>	
								<input name="CourseProperty" value="6" type="radio" class="typeRadio" />双学位必修
								<input name="CourseProperty" value="7" type="radio" class="typeRadio" />双学位限选
								<p class="notice">此项课程性质仅仅适用于该学生成功申请第二专业学位修读计划, 并选择该双学位培养计划的课程选课. </p>
							</div>
							
							<div class="label">
								<b>重修标记</b>
								<input id="Retaking" name="Retaking" value="1" type="checkbox" class="typeRadio" />
							</div>--->
							
							<hr/>
							<div class="lable">
								<input class="button4" type="submit" value="提交" />
							</div>
						</form>
						
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$(":radio[name='StudyType']").change(function(){
								
								if ( $(this).attr("checked") && $(this).val() == "R" ) {
									$(":checkbox[name='Retaking']").attr("checked", "checked");
								} else {
									$(":checkbox[name='Retaking']").removeAttr("checked");
								}
								
								$("#CP_S").addClass("hidden_elem");
								$("#CP_A").addClass("hidden_elem");
								$("#CP_NRF").addClass("hidden_elem");
								
								$(":radio[name='CourseProperty']").removeAttr("checked");
								
								if ( $(this).attr("checked") && $(this).val() == "S" ) {
									$("#CP_S").removeClass("hidden_elem");
									$(":radio[name='CourseProperty'][value='6']").attr("checked", "checked");
								} else if ( $(this).attr("checked") && $(this).val() == "A" ) {
									$("#CP_A").removeClass("hidden_elem");
									$(":radio[name='CourseProperty'][value='4']").attr("checked", "checked");
								} else {
									$("#CP_NRF").removeClass("hidden_elem");
									$(":radio[name='CourseProperty'][value='2']").attr("checked", "checked");
								}
							});
							// -->
							//]]>
						</script>
						
					</div>
					
				</cfif>
				
				<div id="Error" class="tabContent">
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span>错误的参数</h3>
						<p>请先指定 学生 或 课程</p>
					</div>
					
				</div>

			</div>
		</li>
	</ul>
</div>
